<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ArticleEdit.aspx.cs" Inherits="admin.ArticleEdit" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateEditButton="True" DataKeyNames="TopicID" DataSourceID="SqlDataSource1"
            EnableSortingAndPagingCallbacks="True" AutoGenerateColumns="False" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" PageSize="50" AutoGenerateDeleteButton="True">
            <Columns>
                <asp:BoundField DataField="TopicID" HeaderText="TopicID" InsertVisible="False" ReadOnly="True"
                    SortExpression="TopicID" />
                <asp:BoundField DataField="Topic" HeaderText="Topic" SortExpression="Topic" />
                <asp:BoundField DataField="SubTopic" HeaderText="SubTopic" SortExpression="SubTopic" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SpringOfWaterDBConnectionString %>"
            SelectCommand="SELECT * FROM [Topic]" ProviderName="<%$ ConnectionStrings:SpringOfWaterDBConnectionString.ProviderName %>" UpdateCommand="update topic set topic=@topic,subtopic=@subtopic where TopicID = @TopicID" DeleteCommand="delete Topic where TopicID = @TopicID"></asp:SqlDataSource>
        <br />
        <table>
            <tr>
                <td align="right" style="width: 57px">
                    <strong>Title:</strong></td>
                <td style="width: 100px">
                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td>
                <td align="right" style="width: 61px">
                    <strong>Topic:</strong></td>
                <td style="width: 100px">
                    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></td>
                <td align="right" style="width: 68px">
                    <strong>SubTopic:</strong></td>
                <td style="width: 100px">
                    <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox></td>
                <td style="width: 100px">
                    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Search" /></td>
            </tr>
        </table>
        <br />
        <asp:GridView ID="ArticleGridView" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateEditButton="True" DataKeyNames="ArticleID" DataSourceID="SqlDataSource2"
            OnSelectedIndexChanged="ArticleGridView_SelectedIndexChanged" AutoGenerateColumns="False" PageSize="50" AutoGenerateDeleteButton="True">
            <Columns>
                <asp:BoundField DataField="Subject" HeaderText="Title" SortExpression="Subject" />
                <asp:BoundField DataField="CategoryName" HeaderText="CategoryName" SortExpression="CategoryName" />
                <asp:BoundField DataField="ArticleID" HeaderText="ArticleID" InsertVisible="False"
                    ReadOnly="True" SortExpression="ArticleID" />
                <asp:BoundField DataField="PostID" HeaderText="PostID" SortExpression="PostID" />
                <asp:BoundField DataField="Topic" HeaderText="Topic" SortExpression="Topic" />
                <asp:BoundField DataField="SubTopic" HeaderText="SubTopic" SortExpression="SubTopic" />
                <asp:BoundField DataField="BibleTitle" HeaderText="BibleTitle" SortExpression="BibleTitle" />
                <asp:BoundField DataField="BibleChapter" HeaderText="BibleChapter" SortExpression="BibleChapter" />
                <asp:BoundField DataField="BibleSection" HeaderText="BibleSection" SortExpression="BibleSection" />
                <asp:BoundField DataField="BibleChapter_To" HeaderText="BibleChapter_To" SortExpression="BibleChapter_To" />
                <asp:BoundField DataField="BibleSection_To" HeaderText="BibleSection_To" SortExpression="BibleSection_To" />
                <asp:BoundField DataField="Vote_yes" HeaderText="Vote_yes" SortExpression="Vote_yes" />
                <asp:BoundField DataField="Vote_no" HeaderText="Vote_no" SortExpression="Vote_no" />
                <asp:BoundField DataField="ApproveOpinion" HeaderText="ApproveOpinion" SortExpression="ApproveOpinion" />
                <asp:BoundField DataField="ApproveUserID" HeaderText="ApproveUserID" SortExpression="ApproveUserID" />
                <asp:BoundField DataField="ApproveTime" HeaderText="ApproveTime" SortExpression="ApproveTime" />
                <asp:BoundField DataField="URL" HeaderText="URL" SortExpression="URL" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                 ConnectionString="<%$ ConnectionStrings:SpringOfWaterDBConnectionString %>"
                   OnSelecting="SqlDataSource2_Selecting" UpdateCommand="UPDATE Article SET  topic=@topic,subtopic=@subtopic, BibleTitle = @BibleTitle&#13;&#10;,BibleChapter = @BibleChapter, BibleSection = @BibleSection &#13;&#10;,BibleChapter_To = @BibleChapter_to, BibleSection_To = @BibleSection_to&#13;&#10; where ArticleID = @ArticleID&#13;&#10;&#13;&#10;UPDATE ForumPosts Set CategoryID = (select CategoryID from ForumCategories where CategoryName = @CategoryName) where PostID = @PostID" 
                   ProviderName="<%$ ConnectionStrings:SpringOfWaterDBConnectionString.ProviderName %>" DeleteCommand="DELETE FROM Article where ArticleID = @ArticleID">
            <UpdateParameters>
                <asp:Parameter Name="topic" />
                <asp:Parameter Name="subtopic" />
                <asp:Parameter Name="BibleTitle" />
                <asp:Parameter Name="BibleChapter" />
                <asp:Parameter Name="BibleSection" />
                <asp:Parameter Name="BibleChapterto" />
                <asp:Parameter Name="BibleSectionto" />
                <asp:Parameter Name="ArticleID" />
            </UpdateParameters>
        </asp:SqlDataSource>
    
    </div>
    </form>
</body>
</html>
